package com.example.work4.adapter.viewHolder

import android.content.Intent
import android.os.Message
import android.view.View
import android.widget.Button
import android.widget.ImageView
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import com.example.work4.ChatActivity
import com.example.work4.DataUtil
import com.example.work4.R
import com.example.work4.http.data.FriendList

class FriendBaseDataViewHolder(var dataBinding: ViewDataBinding,
                               val avatar: ImageView = dataBinding.root.findViewById(R.id.avatar)): RecyclerView.ViewHolder(dataBinding.root),View.OnClickListener {
    var data = FriendList.FriendBaseData();
    var button: Button = dataBinding.root.findViewById(R.id.status)
    var chat: Button = dataBinding.root.findViewById(R.id.go2chat)
    init {
        chat.setOnClickListener(this)
    }
    override fun onClick(v: View?) {
        when(v?.id){
            R.id.status ->{

            }

            R.id.go2chat ->{
                val intent = Intent()
                intent.putExtra("avatar",data.avatar)
                intent.putExtra("id",data.id)
                intent.putExtra("nickname",data.username)
                intent.setClass(dataBinding.root.context,ChatActivity::class.java)
                dataBinding.root.context.startActivity(intent)
            }
        }
    }

}